﻿package commands 
{
	import flash.utils.ByteArray;
	import commands.classesinfo.*;
	
	/**
	 * ...
	 * @author wwx
	 * 30000007退出桌子返回)
	 */
	public class ExitDeskCmdRsp extends abCommand   
	{
		
		public function ExitDeskCmdRsp() //: abCommand(CommandType.CMD_TYPE_EXITDESK_RSP)   
		{
			super(CommandType(CommandType.CMD_TYPE_EXITDESK_RSP));
//			desksInfo = new Array();
		}
		
		public var msgSeq:int;//消息号
		public var errorNum:int;//错误号
/*		
		public var deskCount:int;//桌子数量N
		public var desksInfo:Array;//DeskInfo
*/		
		public function convertToCmd(bytes:ByteArray, offset:int, len:int):int
		{
			var ret:int = -1;
			msgSeq = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8) + ((int(bytes[offset + 2])) << 16) + ((int(bytes[offset + 3])) << 24);
			offset += 4;
			errorNum = (int) (bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			offset += 4;
/*			
			deskCount = (int) (bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			offset += 4;
			
			//desksInfo = new Array();
			var deskInfo:DeskInfo = null;
			var chairInfo:ChairInfo = null;
			var stringLen:int = 0;
			for (var i:int = 0; i < deskCount; i++)
			{
				deskInfo = new DeskInfo();
				deskInfo.id = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8) + ((int(bytes[offset + 2])) << 16) + ((int(bytes[offset + 3])) << 24);
				offset += 4;
				deskInfo.status = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8) + ((int(bytes[offset + 2])) << 16) + ((int(bytes[offset + 3])) << 24);
				offset += 4;
				
				deskInfo.chairCount = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8) + ((int(bytes[offset + 2])) << 16) + ((int(bytes[offset + 3])) << 24);
				offset += 4;
				//deskInfo.chairsInfo = new Array();
				for (var j:int = 0; j < deskInfo.chairCount; j++)
				{
					chairInfo = new ChairInfo();
					chairInfo.id = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8) + ((int(bytes[offset + 2])) << 16) + ((int(bytes[offset + 3])) << 24);
					offset += 4;
					chairInfo.playerId = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8) + ((int(bytes[offset + 2])) << 16) + ((int(bytes[offset + 3])) << 24);
					offset += 4;
						
					if (0 != chairInfo.playerId)
					{											
						stringLen = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8)
						offset += 2;
						bytes.position = offset;
						chairInfo.playerName = bytes.readMultiByte(stringLen,"gb2312");
						offset += stringLen;
						
						chairInfo.playerStatus = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8) + ((int(bytes[offset + 2])) << 16) + ((int(bytes[offset + 3])) << 24);
						offset += 4;						
					}
					deskInfo.chairsInfo[i] = chairInfo;					
				}
				desksInfo[i] = deskInfo;
			}
*/			
			return 0;
		}		
	}
	
}